<?php

namespace component\system\system_auth;

use think\Validate;

class SystemAuthValidate extends Validate
{
    protected $rule = [
        'pid' => 'integer',
        'title' => 'require|length:1,30',
        'path' => 'length:1,255',
        'desc' => 'length:1,255',
        'route' => 'alphaDash',
    ];

    protected $message = [
        'pid.integer' => '父级ID格式错误',
        'title.require' => '请输入权限名称',
        'title.length' => '权限名称长度不正确,允许的长度1~30',
        'path.length' => '路径长度不正确,允许的长度1~255',
        'desc.length' => '描述长度不正确,允许的长度1~255',
    ];

    public function sceneRestful()
    {
        return $this->only(['pid', 'title','route'])
            ->append('route', 'alphaDash');
    }
}